#ifndef MENU_H
#define MENU_H

#include "base.h"

#define MENU_ITEMS_MAX 16

typedef enum
{
    MENU_ACTION_NONE,
    MENU_ACTION_ENTER,
    MENU_ACTION_RETURN,
} MenuAction;

typedef struct
{
    char caption[32];
    int enabled;
    float offset;
} MenuItem;

typedef struct
{
    int x, y;
    int width;

    int active_item;
    int nb_items;

    MenuItem items[MENU_ITEMS_MAX];

} Menu;

void menu_init(void);
void menu_exit(void);

void menu_initialize(Menu *menu, const char *items[]);

/**
 * \brief Draw a menu to the screen.
 * \param menu Pointer to the menu to render.
 */
void menu_draw(Menu *menu);

/**
 * \brief Draw all menus.
 */
void menu_draw_all();

/**
 * \brief Register a menu for menu_draw_all().
 * \param menu Menu to register.
 */
void menu_draw_register(Menu *menu);

/**
 * \brief Unregister a menu for menu_draw_all().
 * \param menu Menu to unregister.
 */
void menu_draw_unregister(Menu *menu);

/**
 * \brief Check input for a menu.
 *
 * This function handles the input for a menu
 * Navigating inside the menu is automatically handled and transparent to the caller.
 *
 * \param menu Pointer to the menu.
 * \return The action of the user.
 */
MenuAction menu_input_tick(Menu *menu);

// Implementation of the differents menus follows
void menu_main(void);
void menu_new_game(void);
void menu_options(void);
void menu_options_resolution(void);
void menu_options_multisampling(void);
void menu_options_sound(void);
void menu_highscores(void);

void menu_draw_virtual_background(void);

void menu_clear_enabled(Menu *menu);

#endif

